SuperStrict

Framework BRL.StandardIO

Import Otus.StrBuf

Local t%, m%

Const ITERS:Int = 20000

GCCollect
m = GCMemAlloced()
t = MilliSecs()
Local s1:String
For Local i% = 0 Until ITERS
	s1 :+ String(i)
Next
Print (MilliSecs()-t) +"-"+ (GCMemAlloced()-m)

GCCollect
m = GCMemAlloced()
t = MilliSecs()
Local b:TStrBuf = New TStrBuf
For Local i% = 0 Until ITERS
	b.Append String(i)
Next
Local s2:String = b.ToString()
Print (MilliSecs()-t) +"-"+ (GCMemAlloced()-m)

GCCollect
m = GCMemAlloced()
t = MilliSecs()
Local bits:String[ITERS]
For Local i% = 0 Until ITERS
	bits[i] = String(i)
Next
Local s3:String = "".Join(bits)
Print (MilliSecs()-t) +"-"+ (GCMemAlloced()-m)

If s1 <> s2 Print "1<>2"
If s2 <> s3 Print "2<>3"

If String.fromcstring(b.tocstring())<>s1 Print "1<>2c"
If String.fromwstring(b.towstring())<>s1 Print "1<>2w"

If s1[77..777]<>b.SubStr(77,777) Print "substr failed"
If s1[77..777]<>b.SubBuf(77,777).ToString() Print "subbuf failed"

s1 = s1[..66] + "hello" + s1[66..]
b.Insert 66, "hello"
If s1 <> b.ToString() Print "insert failed"

s1 = s1[..666] + "hello" + s1[777..]
b.Replace 666, 777, "hello"
If s1 <> b.ToString() Print "replace failed"

s1 = s1[..666] + s1[777..]
b.Remove 666, 777
If s1 <> b.ToString() Print "remove failed"


